{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Day 7 Agenda \n",
    "\n",
    "1. OOPs - inheritance and Polymorphism\n",
    "2. Libraries and Packages \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Parent Class \n",
    "class animal():\n",
    "    def __init__(self,eat, talk, breed):\n",
    "        self.eat = eat\n",
    "        self.talk = talk\n",
    "        self.breed = breed\n",
    "    def getAnimal(self):\n",
    "        print(\"Breed - \", self.breed)\n",
    "        print(\"Eats - \", self.eat)\n",
    "        print(\"Talks - \",self.talk)\n",
    "    \n",
    "    def setLegs(self):\n",
    "        raise NotImplementedError(\"Hey We need you to implement Set Legs in Child Class \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Child Class \n",
    "class dog(animal):\n",
    "    def __init__(self, name):\n",
    "        animal.__init__(self,\"Carnivores\",  \"Bow Bow\",\"Dog - Bulldog\")\n",
    "        self.name = name\n",
    "    def getName(self):\n",
    "        print(self.name)\n",
    "    def setLegs(self):\n",
    "        print(\"Dog has 4 legs\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "tommy = dog(\"Tommy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dog has 4 legs\n"
     ]
    }
   ],
   "source": [
    "tommy.setLegs()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "class cat(animal):\n",
    "    def __init__(self,name):\n",
    "        animal.__init__(self,\"Fish\",\"Meow\",\"cat\" )\n",
    "        self.name = name \n",
    "    def getCatName(self):\n",
    "        print(self.name)\n",
    "    def setLegs(self):\n",
    "        print(\"Cat has 4 Legs\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "mino = cat(\"mino\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Breed -  cat\n",
      "Eats -  Fish\n",
      "Talks -  Meow\n"
     ]
    }
   ],
   "source": [
    "mino.getAnimal()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cat has 4 Legs\n"
     ]
    }
   ],
   "source": [
    "mino.setLegs()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Polymorphism "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Same name but different tasks \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jambo African Elephant Says D. Trump\n",
      "Alexandar percheron Says Tarun\n"
     ]
    }
   ],
   "source": [
    "class Animal():\n",
    "    def __init__(self,name,breed):\n",
    "        self.name = name \n",
    "        self.breed = breed\n",
    "    \n",
    "    def speak(self):\n",
    "        raise NotImplementedError(\"Sub Class Must Implement Speak Method\")\n",
    "        \n",
    "\n",
    "class Elephant(Animal):\n",
    "    def speak(self):\n",
    "        return self.name + self.breed + ' Says D. Trump'\n",
    "\n",
    "\n",
    "class Horse(Animal):\n",
    "    def speak(self):\n",
    "        return self.name + self.breed+ ' Says Tarun'\n",
    "    \n",
    "Jambo = Elephant('Jambo',' African Elephant')\n",
    "Alexandar = Horse('Alexandar',' percheron')\n",
    "\n",
    "print(Jambo.speak())\n",
    "print(Alexandar.speak())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Animal():\n",
    "    def __init__(self,name,breed):\n",
    "        self.name = name \n",
    "        self.breed = breed\n",
    "    \n",
    "    def speak(self):\n",
    "        raise NotImplementedError(\"Sub Class Must Implement Speak Method\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "class shape():\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "    def area(self):\n",
    "        raise NotImplementedError(\"Hey Define a Area  function for this class\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "class circle(shape):\n",
    "    def __init__ (self, radius):\n",
    "        shape.__init__(self,\"circle\")\n",
    "        self.radius = radius\n",
    "    def area(self):\n",
    "        print(\"Area of Circle - \", 3.14*self.radius*self.radius)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "class square(shape):\n",
    "    def __init__ (self, sides):\n",
    "        shape.__init__(self,\"Square\")\n",
    "        self.sides = sides\n",
    "    def area(self):\n",
    "        print(\"Area of Square - \", self.sides*self.sides)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "abc = square(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Area of Square -  16\n"
     ]
    }
   ],
   "source": [
    "abc.area()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Modules And Packages "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: excel in /opt/anaconda3/lib/python3.7/site-packages (1.0.0)\n",
      "Requirement already satisfied: xlrd in /opt/anaconda3/lib/python3.7/site-packages (from excel) (1.2.0)\n",
      "\u001b[33mWARNING: You are using pip version 20.0.2; however, version 20.2.3 is available.\n",
      "You should consider upgrading via the '/opt/anaconda3/bin/python -m pip install --upgrade pip' command.\u001b[0m\n"
     ]
    }
   ],
   "source": [
    "! pip install excel "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from excel import OpenExcel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['_OpenExcel__hasChar',\n",
       " '_OpenExcel__hasNum',\n",
       " '_OpenExcel__toNum',\n",
       " '__class__',\n",
       " '__delattr__',\n",
       " '__dict__',\n",
       " '__dir__',\n",
       " '__doc__',\n",
       " '__eq__',\n",
       " '__format__',\n",
       " '__ge__',\n",
       " '__getattribute__',\n",
       " '__gt__',\n",
       " '__hash__',\n",
       " '__init__',\n",
       " '__init_subclass__',\n",
       " '__le__',\n",
       " '__lt__',\n",
       " '__module__',\n",
       " '__ne__',\n",
       " '__new__',\n",
       " '__reduce__',\n",
       " '__reduce_ex__',\n",
       " '__repr__',\n",
       " '__setattr__',\n",
       " '__sizeof__',\n",
       " '__str__',\n",
       " '__subclasshook__',\n",
       " '__weakref__',\n",
       " '_convert',\n",
       " 'getCols',\n",
       " 'getRows',\n",
       " 'read']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir(OpenExcel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import xlrd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Book',\n",
       " 'FMLA_TYPE_ARRAY',\n",
       " 'FMLA_TYPE_CELL',\n",
       " 'FMLA_TYPE_COND_FMT',\n",
       " 'FMLA_TYPE_DATA_VAL',\n",
       " 'FMLA_TYPE_NAME',\n",
       " 'FMLA_TYPE_SHARED',\n",
       " 'MMAP_AVAILABLE',\n",
       " 'Operand',\n",
       " 'Ref3D',\n",
       " 'USE_MMAP',\n",
       " 'X12Book',\n",
       " 'XLDateError',\n",
       " 'XLRDError',\n",
       " 'XL_CELL_BLANK',\n",
       " 'XL_CELL_BOOLEAN',\n",
       " 'XL_CELL_DATE',\n",
       " 'XL_CELL_EMPTY',\n",
       " 'XL_CELL_ERROR',\n",
       " 'XL_CELL_NUMBER',\n",
       " 'XL_CELL_TEXT',\n",
       " '__VERSION__',\n",
       " '__builtins__',\n",
       " '__cached__',\n",
       " '__doc__',\n",
       " '__file__',\n",
       " '__loader__',\n",
       " '__name__',\n",
       " '__package__',\n",
       " '__path__',\n",
       " '__spec__',\n",
       " '__version__',\n",
       " 'biff_text_from_num',\n",
       " 'biffh',\n",
       " 'book',\n",
       " 'cellname',\n",
       " 'cellnameabs',\n",
       " 'colname',\n",
       " 'compdoc',\n",
       " 'count_records',\n",
       " 'decompile_formula',\n",
       " 'dump',\n",
       " 'dump_formula',\n",
       " 'empty_cell',\n",
       " 'error_text_from_code',\n",
       " 'evaluate_name_formula',\n",
       " 'formatting',\n",
       " 'formula',\n",
       " 'info',\n",
       " 'mmap',\n",
       " 'oBOOL',\n",
       " 'oERR',\n",
       " 'oNUM',\n",
       " 'oREF',\n",
       " 'oREL',\n",
       " 'oSTRG',\n",
       " 'oUNK',\n",
       " 'okind_dict',\n",
       " 'open_workbook',\n",
       " 'os',\n",
       " 'pprint',\n",
       " 'rangename3d',\n",
       " 'rangename3drel',\n",
       " 'sheet',\n",
       " 'sys',\n",
       " 'timemachine',\n",
       " 'xldate',\n",
       " 'xldate_as_datetime',\n",
       " 'xldate_as_tuple',\n",
       " 'xlsx',\n",
       " 'zipfile']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dir(xlrd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['Email Id', 'amol.muley522@gmail.com', 'poovarasana333@gmail.com', 'vivekadam1332@gmail.com', 'kushashah2002@gmail.com', 'saivenkat.konduru@gmail.com', 'charvyjain3@gmail.com', 'varshverma1@gmail.com', 'varsha1batheja@gmail.com', 'vardhinilatha@gmail.com', 'tigermemon1109@gmail.com', 'thirumaleshaaraveti@gmail.com', 'karthicksakthi124@gmail.com', 'kushashah2002@gmail.com', 'sugandhiprasad7751@gmail.com', 'sugandhikp8@gmail.com', 'poovarasana333@gmail.com', 'ratikeshbajpai@gmail.com', 'sowmyareddyrayi123@gmail.com', 'sonalpalve9999@gmail.com', 'charvyjain3@gmail.com', 'shubhamg457@gmail.com', 'charvyjain3@gmail.com', 'shankarsanjay74@gmail.com', 'sangammelkunde@gmail.com', 'sammetamaheshbabu143@gmail.com', 'ratikeshbajpai@gmail.com', 'sakshi.shivanand123@gmail.com', 'tkousiks@gmail.com', 'saidheerajnaluvala7731@gmail.com', 'bhuvajatin252@gmail.com', 'privatehoonyaar@gmail.com', 'karthicksakthi124@gmail.com', 'milanmmore@gmail.com', 'karthicksakthi124@gmail.com', 'riasapra@gmail.com', 'siddharthsurvey09@gmail.com', 'bhuvajatin252@gmail.com', 'gauravguptagtm@gmail.com', 'poovarasana333@gmail.com', 'gauravguptagtm@gmail.com', 'shreeraj.hariharan@yahoo.com', 'gauravguptagtm@gmail.com', 'milanmmore@gmail.com', 'pooja_kothala@yahoo.com', 'tylajason8@gmail.com', 'bhuvajatin252@gmail.com', 'bhuvajatin252@gmail.com', 'parvinmuskan217@gmail.com', 'goelsarthak2013@gmail.com', 'privatehoonyaar@gmail.com', 'gauravguptagtm@gmail.com', 'nigaikwad00@gmail.com', 'nb67783@gmail.com', 'nandicool1@gmail.com', 'kushashah2002@gmail.com', 'mudgalayushman@gmail.com', 'karthicksakthi124@gmail.com', 'bhuvajatin252@gmail.com', 'kushashah2002@gmail.com', 'bhuvajatin252@gmail.com', 'meghass029@gmail.com', 'meet123upadhayay@gmail.com', 'karthicksakthi124@gmail.com', 'gauravguptagtm@gmail.com', 'lohitha0704@gmail.com', 'lakshitaagarwal23@gmail.com', 'karthicksakthi124@gmail.com', 'bhuvajatin252@gmail.com', 'tkousiks@gmail.com', 'kirtanugohel2746@gmail.com', 'karthicksakthi124@gmail.com', 'karthicksakthi124@gmail.com', 'karthicksakthi124@gmail.com', 'jasper.d.sunder@gmail.com', 'jamodv777@gmail.com', 'poovarasana333@gmail.com', 'developerzeusman007@gmail.com', 'developerzeusman007@gmail.com', 'amol.muley522@gmail.com', 'karthicksakthi124@gmail.com', 'bhuvajatin252@gmail.com', 'shital.0388@gmail.com', 'privatehoonyaar@gmail.com', 'gurudas22051999@gmail.com', 'gauravguptagtm@gmail.com', 'eswararaovalireddi999@gmail.com', 'siddharthsurvey09@gmail.com', 'dyaduwanshi0@gmail.com', 'dudhebhushan933@gmail.com', 'bhuvajatin252@gmail.com', 'karthicksakthi124@gmail.com', 'karthicksakthi124@gmail.com', 'poovarasana333@gmail.com', 'bhuvajatin252@gmail.com', 'kalistaangeline@gmail.com', 'bhuvajatin252@gmail.com', 'privatehoonyaar@gmail.com', 'ashimpatra661@gmail.com', 'ashalingadalli821@gmail.com', 'arunindra18@gmail.com', 'ankitakarnuk2000@gmail.com', 'amol.muley522@gmail.com', 'amitambekar510@gmail.com', 'amol.muley522@gmail.com', 'shadowvj3@gmail.com', 'charvyjain3@gmail.com', 'karthicksakthi124@gmail.com', 'adityananddr2001@gmail.com', 'charvyjain3@gmail.com', 'adharawal@gmail.com', 'karthicksakthi124@gmail.com', 'manasa.gottimukkula12@gmail.com']\n",
      "['Email Id', 'User Id', 'Coins', 'Description']\n",
      "kushashah2002@gmail.com\n"
     ]
    }
   ],
   "source": [
    "from excel import OpenExcel\n",
    "\n",
    "f = OpenExcel('BlockchainEsReferralCoins.xlsx')\n",
    "# print(f.read()) # read all\n",
    "print(f.read('A')) # read 'A' row\n",
    "print(f.read(1)) # f.read('1'), read '1' column\n",
    "print(f.read('A5')) # read 'A5' position"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Lets Write our own Python library"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing moduleOne.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile moduleOne.py\n",
    "print(\"Hey this is ModuleOne\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey this is ModuleOne\n",
      "This isa Python Program, importing Module One\n"
     ]
    }
   ],
   "source": [
    "import moduleOne\n",
    "\n",
    "print(\"This isa Python Program, importing Module One\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "# LEts create a Library for Calculator "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Writing calculatorModule.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile calculatorModule.py\n",
    "\n",
    "def addition(a,b):\n",
    "    print(a+b)\n",
    "\n",
    "def subtract(a,b):\n",
    "    print(a-b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "import calculatorModule\n",
    "\n",
    "calculatorModule.addition(4,5)\n",
    "\n",
    "calculatorModule.subtract(10,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is a file which is getting called In- Directly as Module\n"
     ]
    }
   ],
   "source": [
    "from B7 import LeapYear"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This file is getting called Directly \r\n"
     ]
    }
   ],
   "source": [
    "! python3 B7/LeapYear.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Overwriting oddEven.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile oddEven.py\n",
    "\n",
    "def checkOddOrEven(num):\n",
    "    if num%2==0:\n",
    "        print(\"It is EVEB\")\n",
    "    else:\n",
    "        print(\"It is ODD\")\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    print(\"[oddEven] THis file is now called as Driver Code \")\n",
    "else:\n",
    "    print(\"[oddEven] This file is called as modules\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Overwriting rohiniv.py\n"
     ]
    }
   ],
   "source": [
    "%%writefile rohiniv.py\n",
    "\n",
    "import oddEven\n",
    "\n",
    "oddEven.checkOddOrEven(45)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[oddEven] This file is called as modules\r\n",
      "It is ODD\r\n"
     ]
    }
   ],
   "source": [
    "! python3 rohiniv.py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[oddEven] THis file is now called as Driver Code \r\n"
     ]
    }
   ],
   "source": [
    "! python3 oddEven.py"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Decorators "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Decorators is used for adding extra peice of functionality to the already exsiting code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "def simpleFun():\n",
    "    print(\"HEy this is simple function\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HEy this is simple function\n"
     ]
    }
   ],
   "source": [
    "simpleFun()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function __main__.simpleFun()>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "simpleFun"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "def someOtherFun(name):\n",
    "    print(\"Hey this is a basic Arg function - \",name)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey this is a basic Arg function -  The professor\n"
     ]
    }
   ],
   "source": [
    "someOtherFun(\"The professor\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = \"HEY THis is a gloabl varibale\"\n",
    "\n",
    "def secondFunc():\n",
    "    name = \"Vishal is a local variable\"\n",
    "    print(globals()['s'])\n",
    "    print(locals())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HEY THis is a gloabl varibale\n",
      "{'name': 'Vishal is a local variable'}\n"
     ]
    }
   ],
   "source": [
    "secondFunc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Can we change\" the name of the function just like varibale"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "def oneFunc():\n",
    "    print(\"Hey thsi is one function\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "tempFunc = oneFunc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey thsi is one function\n"
     ]
    }
   ],
   "source": [
    "tempFunc()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function __main__.oneFunc()>"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tempFunc"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Function within the Function ???"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "def hola(name):\n",
    "    print(\"Hey this is hola Function\")\n",
    "    def namaste():\n",
    "        print(\"Hey this is namaste\")\n",
    "    namaste()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey this is hola Function\n",
      "Hey this is namaste\n"
     ]
    }
   ],
   "source": [
    "hola(\"AZbar\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Can we return a FUNction from the function -- Yes we can return a Function from function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "def vanakamm():\n",
    "    \n",
    "    print(\"Hey this is vanakamm\")\n",
    "    \n",
    "    def namaskaram():\n",
    "        print(\"Hey this is Naskaram\")\n",
    "        \n",
    "    return namaskaram"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey this is vanakamm\n"
     ]
    }
   ],
   "source": [
    "kannada = vanakamm()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey this is Naskaram\n"
     ]
    }
   ],
   "source": [
    "kannad()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Can we pass function as Argument ?  - Yes we can !!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "def namaskara(tempFun):\n",
    "    print(\"This is namaskara\")\n",
    "    tempFun()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [],
   "source": [
    "def hello():\n",
    "    print(\"This is hello\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "This is namaskara\n",
      "This is hello\n"
     ]
    }
   ],
   "source": [
    "namaskara(hello)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Decorators \n",
    "def some_function(function_which_needs_wrap):\n",
    "    def wrap_func():\n",
    "        print(\"hey this is a Wrap Function to the some Function\")\n",
    "        function_which_needs_wrap()\n",
    "        print(\"hey this is below code for the wrap to the some function\")        \n",
    "    return wrap_func"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "def hello():\n",
    "    print(\"Hey this is Hello function \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "modified_Hello = some_function(hello)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hey this is a Wrap Function to the some Function\n",
      "Hey this is Hello function \n",
      "hey this is below code for the wrap to the some function\n"
     ]
    }
   ],
   "source": [
    "modified_Hello()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [],
   "source": [
    "@some_function\n",
    "def hey():\n",
    "    print(\"This is Hey Function\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hey this is a Wrap Function to the some Function\n",
      "This is Hey Function\n",
      "hey this is below code for the wrap to the some function\n"
     ]
    }
   ],
   "source": [
    "hey()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getInput(calculate_arg_fun):\n",
    "    def wrap_function():\n",
    "        print(\"Hey people enter two numbers =\")\n",
    "        a = int(input(\"Enter your first Number - \"))\n",
    "        b = int(input(\"Enter your second Number - \"))\n",
    "        calculate_arg_fun(a,b)   \n",
    "    return wrap_function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [],
   "source": [
    "@getInput\n",
    "def addition(num1,num2):\n",
    "    print(\"addition - \",num1 + num2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey people enter two numbers =\n",
      "Enter your first Number - 56\n",
      "Enter your second Number - 34\n",
      "addition -  90\n"
     ]
    }
   ],
   "source": [
    "addition()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "@getInput\n",
    "def subtract(num1,num2):\n",
    "    print(\"Subtract - \", num1-num2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hey people enter two numbers =\n",
      "Enter your first Number - 45\n",
      "Enter your second Number - 23\n",
      "Subtract -  22\n"
     ]
    }
   ],
   "source": [
    "subtract()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
